//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.ruoyi.project.pm.infocheck.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.pm.infocheck.domain.PMInfoCheck;
import com.ruoyi.project.pm.infocheck.service.PMInfoCheckService;
import java.util.List;

import com.ruoyi.project.pro.line.domain.ProLine;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

@Controller
/*@“请求路劲”RequestMapping是一个用来处理请求地址映射的注解,可用于类或方法上。用于类上,
   表示类中的所有响应请求的方法都是以该地址作为父路径。*/
@RequestMapping({"/pm/infocheck"})//
public class PMInfoCheckController extends BaseController {
    private String prefix = "pm/infocheck";
    @Autowired//
    private PMInfoCheckService pmInfoCheckService;
    public PMInfoCheckController() {
    }

    //@“需求权限”验证用户是否登录，等同于方法subject.isAuthenticated() 结果为true时。
    @RequiresPermissions({"pm:infocheck:view"})
    //没数据传来传去就用GET
    @GetMapping
    public String infoCheck() {
        return this.prefix + "/infocheck";
    }

    //@“需求权限”验证用户是否登录，前端传一个ABC，这边是CBA就不会响应请求
    @RequiresPermissions({"pm:infocheck:list"})
    //有数据传来传去就用post（数据在请求体里面）{"/list"}
    @PostMapping({"/list"})
    @ResponseBody
    public TableDataInfo list(PMInfoCheck pmInfoCheck) {
        this.startPage();
        List<PMInfoCheck> list = this.pmInfoCheckService.selectPMInfoCheckList(pmInfoCheck);
        return this.getDataTable(list);
    }

    @GetMapping({"/add"})
    public String add() {
        return this.prefix + "/add";
    }

    @RequiresPermissions({"pm:infocheck:add"})
    @PostMapping({"/add"})
    @ResponseBody
    public AjaxResult add(PMInfoCheck pmInfoCheck) {
        return "1".equals(this.pmInfoCheckService.checkPMInfoCheckNameUnique(pmInfoCheck)) ? this.error("新增项目'" + pmInfoCheck.getInfoCheckType() + "'失败，公告类型名称已存在") : this.toAjax(this.pmInfoCheckService.insertPMInfoCheck(pmInfoCheck));
    }

    @PostMapping({"/checkTypeNameUnique"})
    @ResponseBody
    public String checkTypeNameUnique(PMInfoCheck pmInfoCheck) {
        return this.pmInfoCheckService.checkPMInfoCheckNameUnique(pmInfoCheck);
    }

    @RequiresPermissions({"pm:infocheck:remove"})
    @PostMapping({"/remove"})
    @ResponseBody
    public AjaxResult delete(Integer[] ids) {
        System.out.println("删除方法"+ids);
        return toAjax(pmInfoCheckService.deletePMInfoCheck(ids));
    }

    ///edit/{infoCheckId}


    @GetMapping("/edit/{infoCheckId}")
    public String edit(@PathVariable("infoCheckId") String infoCheckId, ModelMap map)
    {
        PMInfoCheck line = pmInfoCheckService.selectPMInfoCheckById(Integer.valueOf(infoCheckId));
        System.out.println(line);
        map.addAttribute("proLine", line);
        return prefix + "/edit";
    }

}
